/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.commands.connection;

import org.eclipse.gef.commands.Command;

import com.cea.papyrus.core.utils.Debug;
import com.cea.papyrus.diagraminterchange2.di2.GraphEdge;

/**
 * A command to disconnect (remove) a graphEdge from its endpoints.
 * The command can be undone or redone.
 */
public class ConnectionDeleteCommand extends Command {

	/**
	 * Connection instance to disconnect.
	 */
	private final GraphEdge graphEdge;
	
	/**
	 * 
	 */
	private int channel=12;

	/**
	 * Create a command that will disconnect a graphEdge from its endpoints.
	 * 
	 * @param conn the graphEdge instance to disconnect (non-null)
	 * 
	 * @throws IllegalArgumentException if conn is null
	 */ 
	public ConnectionDeleteCommand(GraphEdge conn) {
		if (conn == null) {
			throw new IllegalArgumentException();
		}
		setLabel("graphEdge deletion");
		this.graphEdge = conn;
	}


	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#execute()
	 */
	/**
	 * 
	 */
	@Override
	public void execute() {

		Debug.debug(this,"Call ConnectionDeleteCommand.execute ", channel);

		//boolean b=Manager.getDiagramEditor().getDiagram().getContained().remove(graphEdge);

		//Debug.debug(this,"Call ConnectionDeleteCommand.execute :"+b, channel);

		graphEdge.getContainer().getContained().remove(graphEdge);
		Debug.debug(this,"Call ConnectionDeleteCommand.execute finished ", channel);
		

		//connection.disconnect();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#undo()
	 */
	/**
	 * 
	 */
	@Override
	public void undo() {
		//connection.reconnect();
	}
}
